package win.smartown.easyAdapter;

import android.content.res.Resources;
import android.support.annotation.NonNull;
import android.util.DisplayMetrics;

/**
 * Author:Tiger
 * <p>
 * CrateTime:2017/2/22 15:49
 * <p>
 * Description:
 */
public class Utils {

    public static int getScreenHeight(@NonNull Resources resources) {
        final DisplayMetrics metrics = resources.getDisplayMetrics();
        return metrics.heightPixels;
    }

    public static int getScreenWidth(@NonNull Resources resources) {
        final DisplayMetrics metrics = resources.getDisplayMetrics();
        return metrics.widthPixels;
    }

    public static float getDensity(@NonNull Resources resources) {
        return resources.getDisplayMetrics().density;
    }

    public static int dp2Px(@NonNull Resources resources, int dpValue) {
        return (int) (getDensity(resources) * dpValue);
    }

}
